import java.util.Comparator;
import java.util.Objects;
import java.util.PriorityQueue;

/**
 * @author : zzr
 * @description :
 * @date :
 */

class Card {
    public int rank; //数值
    public String suit; //花色

    public Card(int rank, String suit) {
        this.rank = rank;
        this.suit = suit;
    }
}

class CardComparator implements Comparator<Card> {

    @Override
    public int compare(Card o1, Card o2) {
        if(o1 == o2) {
            return 0;
        }

        if(o1 == null) {
            return -1;
        }

        if(o2 == null) {
            return 1;
        }
        return o1.rank - o2.rank;
    }
}


public class Test {
    public static void main(String[] args) {
        Card p = new Card(1, "♠");
        Card q = new Card(2, "♠");
        Card o = new Card(1, "♠");

        //定义比较器对象
        CardComparator cardComparator = new CardComparator();

        System.out.println(cardComparator.compare(p, q)); // < 0 p比较小
        System.out.println(cardComparator.compare(p, o)); // == 0 牌相等
        System.out.println(cardComparator.compare(q, p)); // > 0 q 比较大

    }
}
